package com.kotlin.dongdong.framework.base

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.kotlin.dongdong.framework.mvp.BaseModel
import com.kotlin.dongdong.framework.mvp.BasePresenter
import com.kotlin.dongdong.framework.utils.TUtil

/**
 * Created by dongdong on 2018/2/2.
 */
abstract class BaseActivity<T : BasePresenter<*, *>, E : BaseModel> : AppCompatActivity() {

    protected var mPresenter: T? = null
    protected var mModel: E? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(getViewId())
        mPresenter = TUtil.getT(this,0)
        mModel = TUtil.getT(this,1)
        this.initPresenter()
        this.initView()
        this.initDate()
        this.initListener()

    }


    abstract fun getViewId(): Int

    abstract fun initPresenter()

    abstract fun initView()

    abstract fun initDate()

    abstract fun initListener()


    override fun onDestroy() {
        super.onDestroy()
        mPresenter!!.onDestroy()
    }

}